﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Threading;
using BlueRoseGames.Controls.Text;

namespace FontPathSample
{
    public partial class Page : UserControl
    {
        int count = 0;
        PolarTransform polarTransform;
        SineTransform sineTransform;
        PerspectiveTransform perspectiveTransform;

        public Page()
        {
            InitializeComponent();
            sineTransform = (tb.TextTransform as BlueRoseGames.Controls.Text.TransformGroup).Children[0] as SineTransform;
            polarTransform = (tb.TextTransform as BlueRoseGames.Controls.Text.TransformGroup).Children[1] as PolarTransform;
            perspectiveTransform = (tb.TextTransform as BlueRoseGames.Controls.Text.TransformGroup).Children[2] as PerspectiveTransform;
            this.DataContext = perspectiveTransform;

            CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
        }

        double angleX = 0;
        double angleY = 0;
        double cameraX = 0;
        double cameraY = 0;

        void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            count += 100;
            if (count % 200 == 0)
            {
                tb.Text = "SOME DYNAMIC TEXT " + count.ToString();
            }
            polarTransform.Angle += .5;
            sineTransform.StartAngle += 3;

            perspectiveTransform.AngleX = Math.Sin(angleX += 0.05) * 5;
            perspectiveTransform.AngleY = Math.Cos(angleY += 0.03) * 8;
            perspectiveTransform.CameraX = polarTransform.CenterX + Math.Sin(cameraX += 0.006) * 60;
            perspectiveTransform.CameraY = polarTransform.CenterY + Math.Sin(cameraY += 0.008) * 50;
        }
    }
}
